package cn.caplike.demo.repository.design.pattern.builder.builder;


import cn.caplike.demo.repository.design.pattern.builder.entity.Person;

import java.util.function.Consumer;

/**
 * @author LiKe
 * @date 2019-06-26 13:44
 */
public class PersonBuilder {

    public String firstName;
    public String middleName;
    public String lastName;

    private PersonBuilder() {
    }

    public PersonBuilder with(Consumer<PersonBuilder> builderConsumer) {
        builderConsumer.accept(this);
        return this;
    }

    public static PersonBuilder of() {
        return new PersonBuilder();
    }

    public Person create() {
        return new Person(firstName, middleName, lastName);
    }
}
